/*
 * out_data.c
 *
 * Created: 24.06.2013 15:04:38
 *  Author: saenko
 */ 


#include "out_data.h"
#include "HD44780.h"
#include "HD44780_translate.h"

void out_data_to_xy(uint16_t data, uint8_t row, uint8_t col) // colum == 0..15 row == 0..1
{
	uint8_t data_tmp;
	uint8_t data_tmp_2;
	
	uint8_t flag_size_data;
	
	lcdGotoXY(row,col);		
	
	data_tmp_2 = data/1000;
	
	flag_size_data = 0;
	
	if(data_tmp_2>0)
		{
			flag_size_data = 1;
			lcdRawSendByte(lcd_trans(data_tmp_2+0x30),1);	
		}		
	
	data_tmp = data%1000;
	
	data_tmp_2 = data_tmp/100;	
	
	lcdRawSendByte(lcd_trans(data_tmp_2+0x30),1);	
	
	lcdRawSendByte(lcd_trans(','),1);		
	
	data_tmp %= 100;
	
	data_tmp_2 = data_tmp/10;	

	lcdRawSendByte(lcd_trans(data_tmp_2+0x30),1);		
	
	if(flag_size_data==0)
		{
			data_tmp_2 = data%10;

			lcdRawSendByte(lcd_trans(data_tmp_2+0x30),1);
		}
		
	
		
}

void out_form(void)
{
	lcdClear();
	
	lcdGotoXY(0,4);
	lcdRawSendByte(lcd_trans('V'),1);	
	
	lcdGotoXY(0,10);
	lcdRawSendByte(lcd_trans('A'),1);
	
	lcdGotoXY(1,4);
	lcdRawSendByte(lcd_trans('W'),1);
		
		
	
}

void out_volt(uint8_t data_adc)
{
	uint16_t data;
	
	data = data_adc * 100;
	data = data/255;
	data = data*5;	

	out_data_to_xy(data,0,0);
	
}

void out_amp(uint8_t data_adc)
{
	uint16_t data;
	
	data = data_adc * 100;
	data = data/255;
	data = data*5;

	out_data_to_xy(data,0,6);
	
}